package offer;

public class offer_0057_1 {
    public int[] twoSum(int[] nums, int target) {
        int len=nums.length;
        int left=0;
        int right=len-1;
        while(left<right){
            if(nums[left]+nums[right]<target){
                left++;
            }
            else if(nums[left]+nums[right]>target){
                right--;
            }
            else {
                int[] result=new int[2];
                result[0]=nums[left];
                result[1]=nums[right];
                return result;

            }
        }
        return new int[0];
    }
}
